/* Ejercicio 3.46
   ejer3_46.c */
#include <stdio.h>

/* funcion main, el programa inicia aca */
int main( void )
{
    int n, counter, i, factorial;
    float e, ex, pow, x;

    printf( "Enter a number: " );
    scanf( "%d", &n );
    i = n;
    factorial = 1;

    while ( i >= 1 ) {
        factorial *= i;
        --i;
    }

    printf( "The factorial is: %d\n", factorial );
    printf( "\n******************************\n\n");

    e = 1;
    counter = 1;
    while ( counter <= 10 ) {
        i = counter;
        factorial = 1;

        while ( i >= 1 ) {
            factorial *= i;
            --i;
        }

        e += 1 / (float) factorial;
        ++counter;
    }

    printf( "e aproximately: %.8f", e );
    printf( "\n******************************\n\n");

    printf( "Enter a number: " );
    scanf( "%f", &x );

    ex = 1;
    counter = 1;
    while ( counter <= 10 ) {
        i = 1;
        pow = 1;

        while ( i <= counter ) {
            pow *= x;
            ++i;
        }

        i = counter;
        factorial = 1;

        while ( i >= 1 ) {
            factorial *= i;
            --i;
        }

        ex += pow / (float) factorial;
        ++counter;
    }

    printf( "e raised to %f is aproximately: %.8f", x, ex );
	return 0;
} /* fin de la funcion main */
